/*
 * Copyright (C) 2010, JDevelopers (jdevelopers@my-pages.org) 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
import static org.junit.Assert.*;

import org.jdevelopers.xarf.XarfSchema;
import org.jdevelopers.xarf.XarfSchemaFactory;
import org.jdevelopers.xarf.exceptions.InvalidSchemaException;
import org.jdevelopers.xarf.exceptions.InvalidSchemaLocationException;
import org.jdevelopers.xarf.exceptions.SchemaReadException;
import org.junit.Test;

/**
 * @author Marcel Hartwig
 *
 */
public class JUnitXarfSchemaParser {

	@Test
	public void testXarfSchemaParser() {
		String schemaLocation = "http://www.x-arf.org/schema/abuse_login-attack_0.1.1.json";
		//String schemaLocation = "http://www.x-arf.org/schema/abuse_malware-attack_0.1.1.json";
		//String schemaLocation = "http://www.x-arf.org/schema/fraud_0.1.1.json";
		try {
			XarfSchema xarfSchema = XarfSchemaFactory.getXarfSchema(schemaLocation);
			assertNotNull(xarfSchema);
			assertEquals(15, xarfSchema.getXarfProperties().length);
			assertTrue(xarfSchema.getXarfProperty("Attachment").isValuePossible("text/plain"));
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InvalidSchemaException e) {
			e.printStackTrace();
		} catch (InvalidSchemaLocationException e) {
			e.printStackTrace();
		} catch (SchemaReadException e) {
			e.printStackTrace();
		}
		
	}
	
}
